//
//  WHTopView.swift
//  8.31-WH微博¡
//
//  Created by 吴涵 on 15/9/10.
//  Copyright © 2015年 wuhan. All rights reserved.
//

import UIKit
import SDWebImage

class WHTopView: UIView {
   
//    /// 友好显示名称
//    var name: String?
//    /// 用户头像地址
//    var profile_image_url: String?

    var statusViewModel:  WHUserStatusModel? {
        didSet{
            nameLabel.text = statusViewModel?.status.user?.name
            iconView.sd_setImageWithURL(statusViewModel?.userIconUrl)
            vipView.image = statusViewModel?.userVipImage
            memberView.image = statusViewModel?.userMemberImage
//            timeLabel.text = statusViewModel?.status.created_at
//            sourceLabel.text = statusViewModel?.status.source

        }
    }
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setUpUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setUpUI(){
        addSubview(iconView)
        addSubview(nameLabel)
        addSubview(memberView)
        addSubview(timeLabel)
        addSubview(sourceLabel)
        addSubview(vipView)
//        print(vipView)
        let offset = CGPoint(x: WHStatusCellMargin, y: 0)
        iconView.ff_AlignInner(type: ff_AlignType.TopLeft, referView: self, size: CGSize(width: WHStatusIconWidth, height: WHStatusIconWidth), offset:CGPoint(x: WHStatusCellMargin, y: WHStatusCellMargin))
        nameLabel.ff_AlignHorizontal(type: ff_AlignType.TopRight, referView: iconView, size: nil, offset: offset)
        memberView.ff_AlignHorizontal(type: ff_AlignType.TopRight, referView: nameLabel, size: nil, offset: offset)
        timeLabel.ff_AlignHorizontal(type: ff_AlignType.BottomRight, referView: iconView, size: nil, offset: offset)
        sourceLabel.ff_AlignHorizontal(type: ff_AlignType.TopRight, referView: timeLabel, size: nil, offset: offset)
    
        vipView.ff_AlignInner(type: ff_AlignType.BottomRight, referView: iconView, size: nil, offset: CGPoint(x: 8, y: 8))

    
    }
    
    private lazy var iconView: UIImageView = UIImageView(image: UIImage(named: "avatar_default_big"))
    private lazy var nameLabel: UILabel = UILabel(title: "吴涵大哥", color: UIColor.darkGrayColor(), fontSize: 14)
    private lazy var memberView: UIImageView = UIImageView(image: UIImage(named: "common_icon_membership_level1"))
    private lazy var timeLabel: UILabel = UILabel(title: "刚刚", color: UIColor.orangeColor(), fontSize: 10)
    private lazy var sourceLabel: UILabel = UILabel(title: "来自 新浪微博", color: UIColor.darkGrayColor(), fontSize: 10)
    private lazy var vipView : UIImageView = UIImageView(image: UIImage(named: "avatar_grassroot"))

}
